package com.plian.system.wrapper.sys.warning;

import com.plian.system.dto.sys.warning.WarningMessageDTO;
import com.plian.system.entity.sys.warning.WarningMessage;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.sys.warning.WarningMessageVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperConstant;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import static com.plian.system.wrapper.util.WrapperConstant.DICT_CODE_TO_NAME;
import static com.plian.system.wrapper.util.WrapperConstant.ORG_ID_TO_NAME;

/**
 * 包装类,返回视图层所需的字段
 *
 * @author gangan
 * @since 2023-04-14
 */
@Mapper(componentModel = WrapperConstant.SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface WarningMessageWrapper extends BaseWrapper<WarningMessage, WarningMessageDTO, WarningMessageVO> {

    @Override
    @Mappings(value = {
            @Mapping(source = "businessModule", target = "businessModuleName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "businessUnit", target = "businessUnitName", qualifiedByName = DICT_CODE_TO_NAME),
            @Mapping(source = "warningOrg", target = "warningOrgName", qualifiedByName = ORG_ID_TO_NAME),
            @Mapping(source = "subordinateGroup", target = "subordinateGroupName", qualifiedByName = ORG_ID_TO_NAME)
    })
    WarningMessageVO entityToVO(WarningMessage entity);
}
